import requests
import pymysql

def download_wordlist(url, filename):
    """直接下载词库文件"""
    try:
        response = requests.get(url, timeout=10)
        response.encoding = 'utf-8'
        with open(filename, 'w', encoding='utf-8') as f:
            f.write(response.text)
        print(f"成功下载: {filename}")
        return True
    except Exception as e:
        print(f"下载失败 {url}: {e}")
        return False

# 选择可访问的链接下载
urls = [
    "https://raw.githubusercontent.com/coco-1/SensitiveWord/main/SensitiveWord.txt",
    "https://gitee.com/mirrors/SensitiveWord/raw/main/SensitiveWord.txt"
]

for url in urls:
    if download_wordlist(url, "sensitive_words.txt"):
        break
